package com.insta.formation.calendar;

import com.insta.formation.calendar.dao.ICalendarDao;
import com.insta.formation.calendar.dao.IPersonDao;
import com.insta.formation.calendar.dao.impl.CalendarDaoImpl;
import com.insta.formation.calendar.dao.impl.PersonDaoImpl;
import com.insta.formation.calendar.manager.ICalendarManager;
import com.insta.formation.calendar.manager.IUserManager;
import com.insta.formation.calendar.manager.impl.CalendarManagerImpl;
import com.insta.formation.calendar.manager.impl.UserManagerImpl;
import com.insta.formation.calendar.model.Calendar;
import com.insta.formation.calendar.model.Person;
import com.insta.formation.calendar.service.IUserService;
import com.insta.formation.calendar.service.IVisitorService;
import com.insta.formation.calendar.service.ws.UserServiceWS;
import com.insta.formation.calendar.service.ws.VisitorServiceWS;

/**
 * Fabrique de l'application.
 * 
 * @author julien
 * 
 */
public enum CalendarFactory {
	INSTANCE;

	/**
	 * Fabrique de classe Service
	 */
	public IVisitorService createVisitorService()
	{
		return new VisitorServiceWS(createUserManager(), createCalendarManager());
	}
	
	public IUserService createUserService()
	{
		return new UserServiceWS(createUserManager(), createCalendarManager());
	}
	
	/**
	 * Fabrique de classe Manager
	 */
	public ICalendarManager createCalendarManager()
	{
		return new CalendarManagerImpl(createCalendarDao());
	}

	public IUserManager createUserManager()
	{
		return new UserManagerImpl(createPersonDao());
	}
	
	/**
	 * Fabrique de classe DAO
	 */
	public ICalendarDao createCalendarDao()
	{
		return new CalendarDaoImpl(Calendar.class);
	}

	public IPersonDao createPersonDao()
	{
		return new PersonDaoImpl(Person.class);
	}
}
